/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.starlink.common.strategy;

import com.starlink.common.enums.OrderTypeEnum;
import com.starlink.model.request.mall.WechatPay;
import com.starlink.model.request.mall.WechatRefund;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhanghong
 * @version PyaNotifyContext.java, v 0.1 2024/7/13 11:10 下午 PyaNotifyContext Exp $$
 */
@Component
public class PayNotifyHandlerContext {

    @Autowired
    private List<IPayNotify> payNotifies;

    public void handle(OrderTypeEnum orderType, WechatPay wechatPay) {
        // 后续业务逻辑处理，策略类实现
        for (IPayNotify payNotify : payNotifies) {
            if (payNotify.supports(orderType.getType())) {
                payNotify.handle(wechatPay);
            }
        }
    }

    public void refundHandle(OrderTypeEnum orderType, WechatRefund wechatPay) {
        // 后续业务逻辑处理，策略类实现
        for (IPayNotify payNotify : payNotifies) {
            if (payNotify.supports(orderType.getType())) {
                payNotify.refundHandle(wechatPay);
            }
        }
    }
}
